home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / MacPNG Library 1.02 / pngMacSrc 1.02 / PNG Library 0.80 / PNG.H < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-29  |  40.6 KB  |  1,107 lines  |  [TEXT/CWIE]

  1.  
  2. /* png.h - header file for png reference library
  3.  
  4.    libpng 1.0 beta 2 - version 0.8
  5.    August 20, 1995
  6.  
  7.    Note: This is a beta version.  It reads and writes valid files
  8.    on the platforms I have, but it has had limited portability
  9.    testing.  Furthermore, you will probably have to modify the
  10.    includes below to get it to work on your system, and you
  11.    may have to supply the correct compiler flags in the makefile.
  12.    Read the readme.txt for more information, and how to contact
  13.    me if you have any problems, or if you want your compiler/
  14.    platform to be supported in the next official libpng release.
  15.  
  16.    See readme.txt for more information
  17.  
  18.    Copyright (c) 1995 Guy Eric Schalnat, Group 42, Inc.
  19.    Contributing Authors:
  20.       Dave Martindale
  21.       Guy Eric Schalnat
  22.       Tim Wegner
  23.  
  24.    The PNG Reference Library is supplied "AS IS". The Contributing Authors
  25.    and Group 42, Inc. disclaim all warranties, expressed or implied,
  26.    including, without limitation, the warranties of merchantability and of
  27.    fitness for any purpose. The Contributing Authors and Group 42, Inc.
  28.    assume no liability for damages, direct or consequential, which may
  29.    result from the use of the PNG Reference Library.
  30.  
  31.    Permission is hereby granted to use, copy, modify, and distribute this
  32.    source code, or portions hereof, for any purpose, without fee, subject
  33.    to the following restrictions:
  34.    1. The origin of this source code must not be misrepresented.
  35.    2. Altered versions must be plainly marked as such and must not be
  36.      misrepresented as being the original source.
  37.    3. This Copyright notice may not be removed or altered from any source or
  38.      altered source distribution.
  39.  
  40.    The Contributing Authors and Group 42, Inc. specifically permit, without
  41.    fee, and encourage the use of this source code as a component to
  42.    supporting the PNG file format in commercial products. If you use this
  43.    source code in a product, acknowledgment is not required but would be
  44.    appreciated.
  45.    */
  46.  
  47. #ifndef _PNG_H
  48. #define _PNG_H
  49.  
  50. /* This is not the place to learn how to use libpng.  The file libpng.txt
  51.    describes how to use libpng, and the file example.c summarizes it
  52.    with some code to build around.  This file is useful for looking
  53.    at the actual function definitions and structure components. */
  54.  
  55. /* include the compression library's header */
  56. #include "zlib.h"
  57.  
  58. /* include all user configurable info */
  59. #include "pngconf.h"
  60.  
  61. /* This file is arranged in several sections.  The first section details
  62.    the functions most users will use.  The third section describes the
  63.    stub files that users will most likely need to change.  The last
  64.    section contains functions used internally by the code.
  65.    */
  66.  
  67. /* version information for png.h - this should match the version
  68.    number in png.c */
  69. #define PNG_LIBPNG_VER_STRING "0.80"
  70. /* careful here.  I wanted to use 080, but that would be octal.  Version
  71.    1.0 will be 100 here, etc. */
  72. #define PNG_LIBPNG_VER 80
  73.  
  74. /* variables defined in png.c - only it needs to define PNG_NO_EXTERN */
  75. #ifndef PNG_NO_EXTERN
  76. /* version information for c files, stored in png.c. This better match
  77.    the version above. */
  78. extern char png_libpng_ver[];
  79. #endif
  80.  
  81. /* three color definitions.  The order of the red, green, and blue, (and the
  82.    exact size) is not important, although the size of the fields need to
  83.    be png_byte or png_uint_16 (as defined below).  While png_color_8 and
  84.    png_color_16 have more fields then they need, they are never used in
  85.    arrays, so the size isn't that important.  I thought about using
  86.    unions, but it looked too clumsy, so I left it. If you're using C++,
  87.    you can union red, index, and gray, if you really want too. */
  88. typedef struct png_color_struct
  89. {
  90.    png_byte red;
  91.    png_byte green;
  92.    png_byte blue;
  93. } png_color;
  94.  
  95. typedef struct png_color_16_struct
  96. {
  97.    png_byte index; /* used for palette files */
  98.    png_uint_16 red; /* for use in red green blue files */
  99.    png_uint_16 green;
  100.    png_uint_16 blue;
  101.    png_uint_16 gray; /* for use in grayscale files */
  102. } png_color_16;
  103.  
  104. typedef struct png_color_8_struct
  105. {
  106.    png_byte red; /* for use in red green blue files */
  107.    png_byte green;
  108.    png_byte blue;
  109.    png_byte gray; /* for use in grayscale files */
  110.    png_byte alpha; /* for alpha channel files */
  111. } png_color_8;
  112.  
  113. /* png_text holds the text in a png file, and whether they are compressed
  114.    or not.  If compression is -1, the text is not compressed.  */
  115. typedef struct png_text_struct
  116. {
  117.    int compression; /* compression value, -1 if uncompressed */
  118.    char *key; /* keyword */
  119.    char *text; /* comment */
  120.    png_uint_32 text_length; /* length of text field */
  121. } png_text;
  122.  
  123. /* png_time is a way to hold the time in an machine independent way.
  124.    Two conversions are provided, both from time_t and struct tm.  There
  125.    is no portable way to convert to either of these structures, as far
  126.    as I know.  If you know of a portable way, send it to me. */
  127. typedef struct png_time_struct
  128. {
  129.    png_uint_16 year; /* full year, as in, 1995 */
  130.    png_byte month; /* month of year, 1 - 12 */
  131.    png_byte day; /* day of month, 1 - 31 */
  132.    png_byte hour; /* hour of day, 0 - 23 */
  133.    png_byte minute; /* minute of hour, 0 - 59 */
  134.    png_byte second; /* second of minute, 0 - 60 (for leap seconds) */
  135. } png_time;
  136.  
  137. /* png_info is a structure that holds the information in a png file.
  138.    If you are reading the file, This structure will tell you what is
  139.    in the png file.  If you are writing the file, fill in the information
  140.    you want to put into the png file, then call png_write_info().
  141.    The names chosen should be very close to the PNG
  142.    specification, so consult that document for information
  143.    about the meaning of each field. */
  144. typedef struct png_info_struct
  145. {
  146.    /* the following are necessary for every png file */
  147.    png_uint_32 width; /* with of file */
  148.    png_uint_32 height; /* height of file */
  149.    png_byte bit_depth; /* 1, 2, 4, 8, or 16 */
  150.    png_byte color_type; /* use the PNG_COLOR_TYPE_ defines */
  151.    png_byte compression_type; /* must be 0 */
  152.    png_byte filter_type; /* must be 0 */
  153.    png_byte interlace_type; /* 0 for non-interlaced, 1 for interlaced */
  154.    png_uint_32 valid; /* the PNG_INFO_ defines, OR'd together */
  155.    /* the following is informational only on read, and not used on
  156.       writes */
  157.    png_byte channels; /* number of channels of data per pixel */
  158.    png_byte pixel_depth; /* number of bits per pixel */
  159.    png_uint_32 rowbytes; /* bytes needed for untransformed row */
  160.    /* the rest are optional.  If you are reading, check the valid
  161.       field to see if the information in these are valid.  If you
  162.       are writing, set the valid field to those chunks you want
  163.       written, and initialize the appropriate fields below */
  164. #if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_WRITE_gAMA_SUPPORTED)
  165.    float gamma; /* gamma value of file, if gAMA chunk is valid */
  166. #endif
  167. #if defined(PNG_READ_sBIT_SUPPORTED) || defined(PNG_WRITE_sBIT_SUPPORTED)
  168.    png_color_8 sig_bit; /* significant bits */
  169. #endif
  170. #if defined(PNG_READ_cHRM_SUPPORTED) || defined(PNG_WRITE_cHRM_SUPPORTED)
  171.    float x_white; /* cHRM chunk values */
  172.    float y_white;
  173.    float x_red;
  174.    float y_red;
  175.    float x_green;
  176.    float y_green;
  177.    float x_blue;
  178.    float y_blue;
  179. #endif
  180.    png_color *palette; /* palette of file */
  181.    png_uint_16 num_palette; /* number of values in palette */
  182.    png_uint_16 num_trans; /* number of trans values */
  183. #if defined(PNG_READ_tRNS_SUPPORTED) || defined(PNG_WRITE_tRNS_SUPPORTED)
  184.    png_byte *trans; /* tRNS values for palette image */
  185.    png_color_16 trans_values; /* tRNS values for non-palette image */
  186. #endif
  187. #if defined(PNG_READ_bKGD_SUPPORTED) || defined(PNG_WRITE_bKGD_SUPPORTED)
  188.    png_color_16 background; /* background color of image */
  189. #endif
  190. #if defined(PNG_READ_hIST_SUPPORTED) || defined(PNG_WRITE_hIST_SUPPORTED)
  191.    png_uint_16 *hist; /* histogram of palette usage */
  192. #endif
  193. #if defined(PNG_READ_pHYs_SUPPORTED) || defined(PNG_WRITE_pHYs_SUPPORTED)
  194.    png_uint_32 x_pixels_per_unit; /* x resolution */
  195.    png_uint_32 y_pixels_per_unit; /* y resolution */
  196.    png_byte phys_unit_type; /* resolution type */
  197. #endif
  198. #if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
  199.    png_uint_32 x_offset; /* x offset on page */
  200.    png_uint_32 y_offset; /* y offset on page */
  201.    png_byte offset_unit_type; /* offset units type */
  202. #endif
  203. #if defined(PNG_READ_tIME_SUPPORTED) || defined(PNG_WRITE_tIME_SUPPORTED)
  204.    png_time mod_time; /* modification time */
  205. #endif
  206. #if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \
  207.     defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED)
  208.    int num_text; /* number of comments */
  209.    int max_text; /* size of text array */
  210.    png_text *text; /* array of comments */
  211. #endif
  212. } png_info;
  213.  
  214. #define PNG_RESOLUTION_UNKNOWN 0
  215. #define PNG_RESOLUTION_METER 1
  216.  
  217. #define PNG_OFFSET_PIXEL 0
  218. #define PNG_OFFSET_MICROMETER 1
  219.  
  220. /* these describe the color_type field in png_info */
  221.  
  222. /* color type masks */
  223. #define PNG_COLOR_MASK_PALETTE 1
  224. #define PNG_COLOR_MASK_COLOR 2
  225. #define PNG_COLOR_MASK_ALPHA 4
  226.  
  227. /* color types.  Note that not all combinations are legal */
  228. #define PNG_COLOR_TYPE_PALETTE \
  229.    (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE)
  230. #define PNG_COLOR_TYPE_RGB (PNG_COLOR_MASK_COLOR)
  231. #define PNG_COLOR_TYPE_GRAY 0
  232. #define PNG_COLOR_TYPE_RGB_ALPHA \
  233.    (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
  234. #define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA)
  235.  
  236. /* These determine if a chunks information is present in a read operation, or
  237.    if the chunk should be written in a write operation.  */
  238. #define PNG_INFO_gAMA 0x0001
  239. #define PNG_INFO_sBIT 0x0002
  240. #define PNG_INFO_cHRM 0x0004
  241. #define PNG_INFO_PLTE 0x0008
  242. #define PNG_INFO_tRNS 0x0010
  243. #define PNG_INFO_bKGD 0x0020
  244. #define PNG_INFO_hIST 0x0040
  245. #define PNG_INFO_pHYs 0x0080
  246. #define PNG_INFO_oFFs 0x0100
  247. #define PNG_INFO_tIME 0x0200
  248.  
  249. /* this is used for the transformation routines, as some of them
  250.    change these values for the row.  It also should enable using
  251.    the routines for other uses. */
  252. typedef struct png_row_info_struct
  253. {
  254.    png_uint_32 width; /* width of row */
  255.    png_uint_32 rowbytes; /* number of bytes in row */
  256.    png_byte color_type; /* color type of row */
  257.    png_byte bit_depth; /* bit depth of row */
  258.    png_byte channels; /* number of channels (1, 2, 3, or 4) */
  259.    png_byte pixel_depth; /* bits per pixel (depth * channels) */
  260. } png_row_info;
  261.  
  262. /* The structure that holds the information to read and write png files.
  263.    The only people who need to care about what is inside of this are the
  264.    people who will be modifying the library for their own special needs.
  265.    */
  266. typedef struct png_struct_def
  267. {
  268.    jmp_buf jmpbuf; /* used in png_error */
  269.    png_byte mode; /* used to determine where we are in the png file */
  270.    png_byte color_type; /* color type of file */
  271.    png_byte bit_depth; /* bit depth of file */
  272.    png_byte interlaced; /* interlace type of file */
  273.    png_byte compession; /* compression type of file */
  274.    png_byte filter; /* filter type */
  275.    png_byte channels; /* number of channels in file */
  276.    png_byte pixel_depth; /* number of bits per pixel */
  277.    png_byte usr_bit_depth; /* bit depth of users row */
  278.    png_byte usr_channels; /* channels at start of write */
  279. #if defined(PNG_READ_GAMMA_SUPPORTED)
  280.    png_byte gamma_shift; /* amount of shift for 16 bit gammas */
  281. #endif
  282.    png_byte pass; /* current pass (0 - 6) */
  283.    png_byte row_init; /* 1 if png_read_start_row() has been called */
  284. #if defined(PNG_READ_BACKGROUND_SUPPORTED)
  285.    png_byte background_gamma_type;
  286.    png_byte background_expand;
  287. #endif
  288.    png_byte zlib_finished;
  289.    png_byte user_palette;
  290. #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
  291.    png_byte filler;
  292.    png_byte filler_loc;
  293. #endif
  294.    png_byte zlib_custom_level; /* one if custom compression level */
  295.    png_byte zlib_custom_method; /* one if custom compression method */
  296.    png_byte zlib_custom_window_bits; /* one if custom compression window bits */
  297.    png_byte zlib_custom_mem_level; /* one if custom compression memory level */
  298.    png_byte zlib_custom_strategy; /* one if custom compression strategy */
  299.    png_byte do_filter; /* one if filtering, zero if not */
  300.    png_byte do_custom_filter; /* one if filtering, zero if not */
  301.    png_uint_16 num_palette; /* number of entries in palette */
  302.    png_uint_16 num_trans; /* number of transparency values */
  303.    int zlib_level; /* holds zlib compression level */
  304.    int zlib_method; /* holds zlib compression method */
  305.    int zlib_window_bits; /* holds zlib compression window bits */
  306.    int zlib_mem_level; /* holds zlib compression memory level */
  307.    int zlib_strategy; /* holds zlib compression strategy */
  308.    png_uint_32 transformations; /* which transformations to perform */
  309.    png_uint_32 crc; /* current crc value */
  310.    png_uint_32 width; /* width of file */
  311.    png_uint_32 height; /* height of file */
  312.    png_uint_32 num_rows; /* number of rows in current pass */
  313.    png_uint_32 rowbytes; /* size of row in bytes */
  314.    png_uint_32 usr_width; /* width of row at start of write */
  315.    png_uint_32 iwidth; /* interlaced width */
  316.    png_uint_32 irowbytes; /* interlaced rowbytes */
  317.    png_uint_32 row_number; /* current row in pass */
  318.    png_uint_32 idat_size; /* current idat size for read */
  319.    png_uint_32 zbuf_size; /* size of zbuf */
  320.    png_color *palette; /* files palette */
  321. #if defined(PNG_READ_DITHER_SUPPORTED)
  322.    png_byte *palette_lookup; /* lookup table for dithering */
  323. #endif
  324. #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
  325.    png_byte *gamma_table; /* gamma table for 8 bit depth files */
  326. #endif
  327. #if defined(PNG_READ_BACKGROUND_SUPPORTED)
  328.    png_byte *gamma_from_1; /* converts from 1.0 to screen */
  329.    png_byte *gamma_to_1; /* converts from file to 1.0 */
  330. #endif
  331. #if defined(PNG_READ_BACKGROUND_SUPPORTED)
  332.    png_byte *trans; /* transparency values for paletted files */
  333. #endif
  334. #if defined(PNG_READ_DITHER_SUPPORTED)
  335.    png_byte *dither_index; /* index translation for palette files */
  336. #endif
  337. #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
  338.    png_uint_16 **gamma_16_table; /* gamma table for 16 bit depth files */
  339. #endif
  340. #if defined(PNG_READ_BACKGROUND_SUPPORTED)
  341.    png_uint_16 **gamma_16_from_1; /* converts from 1.0 to screen */
  342.    png_uint_16 **gamma_16_to_1; /* converts from file to 1.0 */
  343. #endif
  344. #if defined(PNG_READ_DITHER_SUPPORTED)
  345.    png_uint_16 *hist; /* histogram */
  346. #endif
  347.    png_byte *zbuf; /* buffer for zlib */
  348.    png_byte *row_buf; /* row buffer */
  349.    png_byte *prev_row; /* previous row */
  350.    png_byte *save_row; /* place to save row before filtering */
  351.    z_stream *zstream; /* pointer to decompression structure (below) */
  352. #if defined(PNG_READ_GAMMA_SUPPORTED)
  353.    float gamma; /* file gamma value */
  354.    float display_gamma; /* display gamma value */
  355. #endif
  356. #if defined(PNG_READ_BACKGROUND_SUPPORTED)
  357.    float background_gamma;
  358. #endif
  359. #if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
  360.    png_color_8 shift; /* shift for significant bit tranformation */
  361. #endif
  362. #if defined(PNG_READ_GAMMA_SUPPORTED)
  363.    png_color_8 sig_bit; /* significant bits in file */
  364. #endif
  365. #if defined(PNG_READ_BACKGROUND_SUPPORTED)
  366.    png_color_16 trans_values; /* transparency values for non-paletted files */
  367.    png_color_16 background; /* background color, gamma corrected for screen */
  368. #if defined(PNG_READ_GAMMA_SUPPORTED)
  369.    png_color_16 background_1; /* background normalized to gamma 1.0 */
  370. #endif
  371. #endif
  372.    png_row_info row_info; /* used for transformation routines */
  373.    z_stream zstream_struct; /* decompression structure */
  374.    FILE *fp; /* used for png_read and png_write */
  375. } png_struct;
  376.  
  377.  
  378. /* Here are the function definitions most commonly used.  This is not
  379.    the place to find out how to use libpng.  See libpng.txt for the
  380.    full explanation, see example.c for the summary.  This just provides
  381.    a simple one line of the use of each function. */
  382.  
  383. /* check the first 1 - 8 bytes to see if it is a png file */
  384. extern int png_check_sig PNGARG((png_byte *sig, int num));
  385.  
  386. /* initialize png structure for reading, and allocate any memory needed */
  387. extern void png_read_init PNGARG((png_struct *png_ptr));
  388.  
  389. /* initialize png structure for writing, and allocate any memory needed */
  390. extern void png_write_init PNGARG((png_struct *png_ptr));
  391.  
  392. /* initialize the info structure */
  393. extern void png_info_init PNGARG((png_info *info));
  394.  
  395. /* Writes all the png information before the image. */
  396. extern void png_write_info PNGARG((png_struct *png_ptr, png_info *info));
  397.  
  398. /* read the information before the actual image data. */
  399. extern void png_read_info PNGARG((png_struct *png_ptr, png_info *info));
  400.  
  401. #if defined(PNG_READ_tIME_SUPPORTED)
  402. /* convert from a struct tm to png_time */
  403. extern void png_convert_from_struct_tm PNGARG((png_time *ptime,
  404.    struct tm *ttime));
  405.  
  406. /* convert from time_t to png_time.  Uses gmtime() */
  407. extern void png_convert_from_time_t PNGARG((png_time *ptime, time_t ttime));
  408. #endif
  409.  
  410. #if defined(PNG_READ_EXPAND_SUPPORTED)
  411. /* Expand the data to 24 bit RGB, or 8 bit Grayscale,
  412.    with alpha if necessary. */
  413. extern void png_set_expand PNGARG((png_struct *png_ptr));
  414. #endif
  415.  
  416. #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
  417. /* Use blue, green, red order for pixels. */
  418. extern void png_set_bgr PNGARG((png_struct *png_ptr));
  419. #endif
  420.  
  421. #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
  422. #define PNG_FILLER_BEFORE 0
  423. #define PNG_FILLER_AFTER 1
  424. /* Add a filler byte to rgb images. */
  425. extern void png_set_filler PNGARG((png_struct *png_ptr, int filler,
  426.    int filler_loc));
  427.  
  428. /* old ways of doing this, still supported through 1.x for backwards
  429.    compatability, but not suggested */
  430.  
  431. /* Add a filler byte to rgb images after the colors. */
  432. extern void png_set_rgbx PNGARG((png_struct *png_ptr));
  433.  
  434. /* Add a filler byte to rgb images before the colors. */
  435. extern void png_set_xrgb PNGARG((png_struct *png_ptr));
  436. #endif
  437.  
  438. #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
  439. /* Swap bytes in 16 bit depth files. */
  440. extern void png_set_swap PNGARG((png_struct *png_ptr));
  441. #endif
  442.  
  443. #if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
  444. /* Use 1 byte per pixel in 1, 2, or 4 bit depth files. */
  445. extern void png_set_packing PNGARG((png_struct *png_ptr));
  446. #endif
  447.  
  448. #if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
  449. /* Converts files to legal bit depths. */
  450. extern void png_set_shift PNGARG((png_struct *png_ptr,
  451.    png_color_8 *true_bits));
  452. #endif
  453.  
  454. #if defined(PNG_READ_INTERLACING_SUPPORTED) || \
  455.     defined(PNG_WRITE_INTERLACING_SUPPORTED)
  456. /* Have the code handle the interlacing.  Returns the number of passes. */
  457. extern int png_set_interlace_handling PNGARG((png_struct *png_ptr));
  458. #endif
  459.  
  460. #if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
  461. /* Invert monocrome files */
  462. extern void png_set_invert_mono PNGARG((png_struct *png_ptr));
  463. #endif
  464.  
  465. #if defined(PNG_READ_BACKGROUND_SUPPORTED)
  466. /* Handle alpha and tRNS by replacing with a background color. */
  467. #define PNG_BACKGROUND_GAMMA_SCREEN 0
  468. #define PNG_BACKGROUND_GAMMA_FILE 1
  469. #define PNG_BACKGROUND_GAMMA_UNIQUE 2
  470. #define PNG_BACKGROUND_GAMMA_UNKNOWN 3
  471. extern void png_set_background PNGARG((png_struct *png_ptr,
  472.    png_color_16 *background_color, int background_gamma_code,
  473.    int need_expand, double background_gamma));
  474. #endif
  475.  
  476. #if defined(PNG_READ_16_TO_8_SUPPORTED)
  477. /* strip the second byte of information from a 16 bit depth file. */
  478. extern void png_set_strip_16 PNGARG((png_struct *png_ptr));
  479. #endif
  480.  
  481. #if defined(PNG_GRAY_TO_RGB_SUPPORTED)
  482. /* convert a grayscale file into rgb. */
  483. extern void png_set_gray_to_rgb PNGARG((png_struct *png_ptr));
  484. #endif
  485.  
  486. #if defined(PNG_READ_DITHER_SUPPORTED)
  487. /* Turn on dithering, and reduce the palette to the number of colors available. */
  488. extern void png_set_dither PNGARG((png_struct *png_ptr, png_color *palette,
  489.    int num_palette, int maximum_colors, png_uint_16 *histogram, int full_dither));
  490. #endif
  491.  
  492. #if defined(PNG_READ_GAMMA_SUPPORTED)
  493. /* Handle gamma correction. */
  494. extern void png_set_gamma PNGARG((png_struct *png_ptr, double screen_gamma,
  495.    double default_file_gamma));
  496. #endif
  497.  
  498. /* optional update palette with requested transformations */
  499. extern void png_start_read_image PNGARG((png_struct *png_ptr));
  500.  
  501. /* optional call to update the users info structure */
  502. extern void png_read_update_info PNGARG((png_struct *png_ptr,
  503.    png_info *info_ptr));
  504.  
  505. /* read a one or more rows of image data.*/
  506. extern void png_read_rows PNGARG((png_struct *png_ptr,
  507.    png_byte **row,
  508.    png_byte **display_row, png_uint_32 num_rows));
  509.  
  510. /* read a row of data.*/
  511. extern void png_read_row PNGARG((png_struct *png_ptr,
  512.    png_byte *row,
  513.    png_byte *display_row));
  514.  
  515. /* read the whole image into memory at once. */
  516. extern void png_read_image PNGARG((png_struct *png_ptr,
  517.    png_byte **image));
  518.  
  519. /* write a row of image data */
  520. extern void png_write_row PNGARG((png_struct *png_ptr,
  521.    png_byte *row));
  522.  
  523. /* write a few rows of image data */
  524. extern void png_write_rows PNGARG((png_struct *png_ptr,
  525.    png_byte **row,
  526.    png_uint_32 num_rows));
  527.  
  528. /* write the image data */
  529. extern void png_write_image PNGARG((png_struct *png_ptr, png_byte **image));
  530.  
  531. /* writes the end of the png file. */
  532. extern void png_write_end PNGARG((png_struct *png_ptr, png_info *info));
  533.  
  534. /* read the end of the png file. */
  535. extern void png_read_end PNGARG((png_struct *png_ptr, png_info *info));
  536.  
  537. /* free all memory used by the read */
  538. extern void png_read_destroy PNGARG((png_struct *png_ptr, png_info *info,
  539.    png_info *end_info));
  540.  
  541. /* free any memory used in png struct */
  542. extern void png_write_destroy PNGARG((png_struct *png_ptr));
  543.  
  544. /* These functions give the user control over the filtering and
  545.    compression libraries used by zlib.  These functions are mainly
  546.    useful for testing, as the defaults should work with most users.
  547.    Those users who are tight on memory, or are wanting faster
  548.    performance at the expense of compression can modify them.
  549.    See the compression library header file for an explination
  550.    of these functions */
  551. extern void png_set_filtering PNGARG((png_struct *png_ptr, int filter));
  552.  
  553. extern void png_set_compression_level PNGARG((png_struct *png_ptr,
  554.    int level));
  555.  
  556. extern void png_set_compression_mem_level PNGARG((png_struct *png_ptr,
  557.    int mem_level));
  558.  
  559. extern void png_set_compression_strategy PNGARG((png_struct *png_ptr,
  560.    int strategy));
  561.  
  562. extern void png_set_compression_window_bits PNGARG((png_struct *png_ptr,
  563.    int window_bits));
  564.  
  565. extern void png_set_compression_method PNGARG((png_struct *png_ptr,
  566.    int method));
  567.  
  568. /* These next functions are stubs of typical c functions for input/output,
  569.    memory, and error handling.  They are in the file pngstub.c, and are
  570.    set up to be easily modified for users that need to.  See the file
  571.    pngstub.c for more information */
  572.  
  573. /* Write the data to whatever output you are using. */
  574. extern void png_write_data PNGARG((png_struct *png_ptr, png_byte *data,
  575.    png_uint_32 length));
  576.  
  577. /* Read data from whatever input you are using */
  578. extern void png_read_data PNGARG((png_struct *png_ptr, png_byte *data,
  579.    png_uint_32 length));
  580.  
  581. /* Initialize the input/output for the png file. */
  582. extern void png_init_io PNGARG((png_struct *png_ptr, FILE *fp));
  583.  
  584. /* Allocate memory in larger chunks. */
  585. extern void *png_large_malloc PNGARG((png_struct *png_ptr, png_uint_32 size));
  586.  
  587. /* free's a pointer allocated by png_large_malloc() */
  588. extern void png_large_free PNGARG((png_struct *png_ptr, void *ptr));
  589.  
  590. /* Allocate memory. */
  591. extern void *png_malloc PNGARG((png_struct *png_ptr, png_uint_32 size));
  592.  
  593. /* Reallocate memory. */
  594. extern void *png_realloc PNGARG((png_struct *png_ptr, void *ptr,
  595.    png_uint_32 size, png_uint_32 old_size));
  596.  
  597. /* free's a pointer allocated by png_malloc() */
  598. extern void png_free PNGARG((png_struct *png_ptr, void *ptr));
  599.  
  600. /* Fatal error in libpng - can't continue */
  601. extern void png_error PNGARG((png_struct *png_ptr, char *error));
  602.  
  603. /* Non-fatal error in libpng.  Can continue, but may have a problem. */
  604. extern void png_warning PNGARG((png_struct *png_ptr, char *message));
  605.  
  606.  
  607. /* These next functions are used internally in the code.  If you use
  608.    them, make sure you read and understand the png spec.  More information
  609.    about them can be found in the files where the functions are.
  610.    Feel free to move any of these outside the PNG_INTERNAL define if
  611.    you just need a few of them, but if you need access to more, you should
  612.    define PNG_INTERNAL inside your code, so everyone who includes png.h
  613.    won't get yet another definition the compiler has to deal with. */
  614.  
  615. #ifdef PNG_INTERNAL
  616.  
  617. /* various modes of operation.  Note that after an init, mode is set to
  618.    zero automatically */
  619. #define PNG_BEFORE_IHDR 0
  620. #define PNG_HAVE_IHDR 1
  621. #define PNG_HAVE_PLTE 2
  622. #define PNG_HAVE_IDAT 3
  623. #define PNG_AT_LAST_IDAT 4
  624. #define PNG_AFTER_IDAT 5
  625. #define PNG_AFTER_IEND 6
  626.  
  627. /* defines for the transformations the png library does on the image data */
  628. #define PNG_BGR 0x0001
  629. #define PNG_INTERLACE 0x0002
  630. #define PNG_PACK 0x0004
  631. #define PNG_SHIFT 0x0008
  632. #define PNG_SWAP_BYTES 0x0010
  633. #define PNG_INVERT_MONO 0x0020
  634. #define PNG_DITHER 0x0040
  635. #define PNG_BACKGROUND 0x0080
  636. #define PNG_XRGB 0x0100
  637. #define PNG_16_TO_8 0x0200
  638. #define PNG_RGBA 0x0400
  639. #define PNG_EXPAND 0x0800
  640. #define PNG_GAMMA 0x1000
  641. #define PNG_GRAY_TO_RGB 0x2000
  642. #define PNG_FILLER 0x4000
  643.  
  644. /* save typing and make code easier to understand */
  645. #define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \
  646.    abs((int)((c1).green) - (int)((c2).green)) + \
  647.    abs((int)((c1).blue) - (int)((c2).blue)))
  648.  
  649. /* variables defined in png.c - only it needs to define PNG_NO_EXTERN */
  650. #ifndef PNG_NO_EXTERN
  651. /* place to hold the signiture string for a png file. */
  652. extern png_byte png_sig[];
  653.  
  654. /* version information for c files, stored in png.c. */
  655. extern char png_libpng_ver[];
  656.  
  657. /* constant strings for known chunk types.  If you need to add a chunk,
  658.    add a string holding the name here.  See png.c for more details */
  659. extern png_byte png_IHDR[];
  660. extern png_byte png_IDAT[];
  661. extern png_byte png_IEND[];
  662. extern png_byte png_PLTE[];
  663. #if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_WRITE_gAMA_SUPPORTED)
  664. extern png_byte png_gAMA[];
  665. #endif
  666. #if defined(PNG_READ_sBIT_SUPPORTED) || defined(PNG_WRITE_sBIT_SUPPORTED)
  667. extern png_byte png_sBIT[];
  668. #endif
  669. #if defined(PNG_READ_cHRM_SUPPORTED) || defined(PNG_WRITE_cHRM_SUPPORTED)
  670. extern png_byte png_cHRM[];
  671. #endif
  672. #if defined(PNG_READ_tRNS_SUPPORTED) || defined(PNG_WRITE_tRNS_SUPPORTED)
  673. extern png_byte png_tRNS[];
  674. #endif
  675. #if defined(PNG_READ_bKGD_SUPPORTED) || defined(PNG_WRITE_bKGD_SUPPORTED)
  676. extern png_byte png_bKGD[];
  677. #endif
  678. #if defined(PNG_READ_hIST_SUPPORTED) || defined(PNG_WRITE_hIST_SUPPORTED)
  679. extern png_byte png_hIST[];
  680. #endif
  681. #if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED)
  682. extern png_byte png_tEXt[];
  683. #endif
  684. #if defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED)
  685. extern png_byte png_zTXt[];
  686. #endif
  687. #if defined(PNG_READ_pHYs_SUPPORTED) || defined(PNG_WRITE_pHYs_SUPPORTED)
  688. extern png_byte png_pHYs[];
  689. #endif
  690. #if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
  691. extern png_byte png_oFFs[];
  692. #endif
  693. #if defined(PNG_READ_tIME_SUPPORTED) || defined(PNG_WRITE_tIME_SUPPORTED)
  694. extern png_byte png_tIME[];
  695. #endif
  696. /* Structures to facilitate easy interlacing.  See png.c for more details */
  697. extern int png_pass_start[];
  698. extern int png_pass_inc[];
  699. extern int png_pass_ystart[];
  700. extern int png_pass_yinc[];
  701. /* these are not currently used.  If you need them, see png.c
  702. extern int png_pass_width[];
  703. extern int png_pass_height[];
  704. */
  705. extern int png_pass_mask[];
  706. extern int png_pass_dsp_mask[];
  707.  
  708. #endif /* PNG_NO_EXTERN */
  709.  
  710. /* Function to allocate memory for zlib. */
  711. extern voidp png_zalloc PNGARG((voidp png_ptr, uInt items, uInt size));
  712.  
  713. /* function to free memory for zlib */
  714. extern void png_zfree PNGARG((voidp png_ptr, voidp ptr));
  715.  
  716. /* reset the crc variable */
  717. extern void png_reset_crc PNGARG((png_struct *png_ptr));
  718.  
  719. /* calculate the crc over a section of data.  Note that while we
  720.    are passing in a 32 bit value for length, on 16 bit machines, you
  721.    would need to use huge pointers to access all that data.  See the
  722.    code in png.c for more information. */
  723. extern void png_calculate_crc PNGARG((png_struct *png_ptr, png_byte *ptr,
  724.    png_uint_32 length));
  725.  
  726. /* place a 32 bit number into a buffer in png byte order.  We work
  727.    with unsigned numbers for convenience, you may have to cast
  728.    signed numbers (if you use any, most png data is unsigned). */
  729. extern void png_save_uint_32 PNGARG((png_byte *buf, png_uint_32 i));
  730.  
  731. /* place a 16 bit number into a buffer in png byte order */
  732. extern void png_save_uint_16 PNGARG((png_byte *buf, png_uint_16 i));
  733.  
  734. /* write a 32 bit number */
  735. extern void png_write_uint_32 PNGARG((png_struct *png_ptr, png_uint_32 i));
  736.  
  737. /* write a 16 bit number */
  738. extern void png_write_uint_16 PNGARG((png_struct *png_ptr, png_uint_16 i));
  739.  
  740. /* Write a png chunk.  */
  741. extern void png_write_chunk PNGARG((png_struct *png_ptr, png_byte *type,
  742.    png_byte *data, png_uint_32 length));
  743.  
  744. /* Write the start of a png chunk. */
  745. extern void png_write_chunk_start PNGARG((png_struct *png_ptr, png_byte *type,
  746.    png_uint_32 total_length));
  747.  
  748. /* write the data of a png chunk started with png_write_chunk_start(). */
  749. extern void png_write_chunk_data PNGARG((png_struct *png_ptr, png_byte *data,
  750.    png_uint_32 length));
  751.  
  752. /* finish a chunk started with png_write_chunk_start() */
  753. extern void png_write_chunk_end PNGARG((png_struct *png_ptr));
  754.  
  755. /* simple function to write the signiture */
  756. extern void png_write_sig PNGARG((png_struct *png_ptr));
  757.  
  758. /* write various chunks */
  759.  
  760. /* Write the IHDR chunk, and update the png_struct with the necessary
  761.    information. */
  762. extern void png_write_IHDR PNGARG((png_struct *png_ptr, png_uint_32 width,
  763.    png_uint_32 height,
  764.    int bit_depth, int color_type, int compression_type, int filter_type,
  765.    int interlace_type));
  766.  
  767. extern void png_write_PLTE PNGARG((png_struct *png_ptr, png_color *palette,
  768.    int number));
  769.  
  770. extern void png_write_IDAT PNGARG((png_struct *png_ptr, png_byte *data,
  771.    png_uint_32 length));
  772.  
  773. extern void png_write_IEND PNGARG((png_struct *png_ptr));
  774.  
  775. #if defined(PNG_WRITE_gAMA_SUPPORTED)
  776. extern void png_write_gAMA PNGARG((png_struct *png_ptr, float gamma));
  777. #endif
  778.  
  779. #if defined(PNG_WRITE_sBIT_SUPPORTED)
  780. extern void png_write_sBIT PNGARG((png_struct *png_ptr, png_color_8 *sbit,
  781.    int color_type));
  782. #endif
  783.  
  784. #if defined(PNG_WRITE_cHRM_SUPPORTED)
  785. extern void png_write_cHRM PNGARG((png_struct *png_ptr,
  786.    float white_x, float white_y,
  787.    float red_x, float red_y, float green_x, float green_y,
  788.    float blue_x, float blue_y));
  789. #endif
  790.  
  791. #if defined(PNG_WRITE_tRNS_SUPPORTED)
  792. extern void png_write_tRNS PNGARG((png_struct *png_ptr, png_byte *trans,
  793.    png_color_16 *values, int number, int color_type));
  794. #endif
  795.  
  796. #if defined(PNG_WRITE_bKGD_SUPPORTED)
  797. extern void png_write_bKGD PNGARG((png_struct *png_ptr, png_color_16 *values,
  798.    int color_type));
  799. #endif
  800.  
  801. #if defined(PNG_WRITE_hIST_SUPPORTED)
  802. extern void png_write_hIST PNGARG((png_struct *png_ptr, png_uint_16 *hist,
  803.    int number));
  804. #endif
  805.  
  806. #if defined(PNG_WRITE_tEXt_SUPPORTED)
  807. extern void png_write_tEXt PNGARG((png_struct *png_ptr, char *key,
  808.    char *text, png_uint_32 text_len));
  809. #endif
  810.  
  811. #if defined(PNG_WRITE_zTXt_SUPPORTED)
  812. extern void png_write_zTXt PNGARG((png_struct *png_ptr, char *key,
  813.    char *text, png_uint_32 text_len, int compression));
  814. #endif
  815.  
  816. #if defined(PNG_WRITE_pHYs_SUPPORTED)
  817. extern void png_write_pHYs PNGARG((png_struct *png_ptr,
  818.    png_uint_32 x_pixels_per_unit,
  819.    png_uint_32 y_pixels_per_unit,
  820.    int unit_type));
  821. #endif
  822.  
  823. #if defined(PNG_WRITE_oFFs_SUPPORTED)
  824. extern void png_write_oFFs PNGARG((png_struct *png_ptr,
  825.    png_uint_32 x_offset,
  826.    png_uint_32 y_offset,
  827.    int unit_type));
  828. #endif
  829.  
  830. #if defined(PNG_WRITE_tIME_SUPPORTED)
  831. extern void png_write_tIME PNGARG((png_struct *png_ptr, png_time *mod_time));
  832. #endif
  833.  
  834. /* Internal use only.   Called when finished processing a row of data */
  835. extern void png_write_finish_row PNGARG((png_struct *png_ptr));
  836.  
  837. /* Internal use only.   Called before first row of data */
  838. extern void png_write_start_row PNGARG((png_struct *png_ptr));
  839.  
  840. /* callbacks for png chunks */
  841. extern void png_read_IHDR PNGARG((png_struct *png_ptr, png_info *info,
  842.    png_uint_32 width, png_uint_32 height, int bit_depth,
  843.    int color_type, int compression_type, int filter_type,
  844.    int interlace_type));
  845.  
  846. extern void png_read_PLTE PNGARG((png_struct *png_ptr, png_info *info,
  847.    png_color *palette, int num));
  848.  
  849. #if defined(PNG_READ_gAMA_SUPPORTED)
  850. extern void png_read_gAMA PNGARG((png_struct *png_ptr, png_info *info,
  851.    float gamma));
  852. #endif
  853.  
  854. #if defined(PNG_READ_sBIT_SUPPORTED)
  855. extern void png_read_sBIT PNGARG((png_struct *png_ptr, png_info *info,
  856.    png_color_8 *sig_bit));
  857. #endif
  858.  
  859. #if defined(PNG_READ_cHRM_SUPPORTED)
  860. extern void png_read_cHRM PNGARG((png_struct *png_ptr, png_info *info,
  861.    float white_x, float white_y, float red_x, float red_y,
  862.    float green_x, float green_y, float blue_x, float blue_y));
  863. #endif
  864.  
  865. #if defined(PNG_READ_tRNS_SUPPORTED)
  866. extern void png_read_tRNS PNGARG((png_struct *png_ptr, png_info *info,
  867.    png_byte *trans, int num_trans,   png_color_16 *trans_values));
  868. #endif
  869.  
  870. #if defined(PNG_READ_bKGD_SUPPORTED)
  871. extern void png_read_bKGD PNGARG((png_struct *png_ptr, png_info *info,
  872.    png_color_16 *background));
  873. #endif
  874.  
  875. #if defined(PNG_READ_hIST_SUPPORTED)
  876. extern void png_read_hIST PNGARG((png_struct *png_ptr, png_info *info,
  877.    png_uint_16 *hist));
  878. #endif
  879.  
  880. #if defined(PNG_READ_pHYs_SUPPORTED)
  881. extern void png_read_pHYs PNGARG((png_struct *png_ptr, png_info *info,
  882.    png_uint_32 res_x, png_uint_32 res_y, int unit_type));
  883. #endif
  884.  
  885. #if defined(PNG_READ_oFFs_SUPPORTED)
  886. extern void png_read_oFFs PNGARG((png_struct *png_ptr, png_info *info,
  887.    png_uint_32 offset_x, png_uint_32 offset_y, int unit_type));
  888. #endif
  889.  
  890. #if defined(PNG_READ_tIME_SUPPORTED)
  891. extern void png_read_tIME PNGARG((png_struct *png_ptr, png_info *info,
  892.    png_time *mod_time));
  893. #endif
  894.  
  895. #if defined(PNG_READ_tEXt_SUPPORTED)
  896. extern void png_read_tEXt PNGARG((png_struct *png_ptr, png_info *info,
  897.    char *key, char *text, png_uint_32 text_len));
  898. #endif
  899.  
  900. #if defined(PNG_READ_zTXt_SUPPORTED)
  901. extern void png_read_zTXt PNGARG((png_struct *png_ptr, png_info *info,
  902.    char *key, char *text, png_uint_32 text_len, int compression));
  903. #endif
  904.  
  905. #if defined(PNG_READ_GAMMA_SUPPORTED)
  906. void
  907. png_build_gamma_table PNGARG((png_struct *png_ptr));
  908. #endif
  909.  
  910. /* combine a row of data, dealing with alpha, etc. if requested */
  911. extern void png_combine_row PNGARG((png_struct *png_ptr, png_byte *row,
  912.    int mask));
  913.  
  914. #if defined(PNG_READ_INTERLACING_SUPPORTED)
  915. /* expand an interlaced row */
  916. extern void png_do_read_interlace PNGARG((png_row_info *row_info,
  917.    png_byte *row, int pass));
  918. #endif
  919.  
  920. #if defined(PNG_WRITE_INTERLACING_SUPPORTED)
  921. /* grab pixels out of a row for an interlaced pass */
  922. extern void png_do_write_interlace PNGARG((png_row_info *row_info,
  923.    png_byte *row, int pass));
  924. #endif
  925.  
  926. /* unfilter a row */
  927. extern void png_read_filter_row PNGARG((png_row_info *row_info,
  928.    png_byte *row, png_byte *prev_row, int filter));
  929. /* filter a row, and place the correct filter byte in the row */
  930. extern void png_write_filter_row PNGARG((png_row_info *row_info,
  931.    png_byte *row, png_byte *prev_row));
  932. /* finish a row while reading, dealing with interlacing passes, etc. */
  933. extern void png_read_finish_row PNGARG((png_struct *png_ptr));
  934. /* initialize the row buffers, etc. */
  935. extern void png_read_start_row PNGARG((png_struct *png_ptr));
  936. /* optional call to update the users info structure */
  937. extern void png_read_transform_info PNGARG((png_struct *png_ptr,
  938.    png_info *info_ptr));
  939.  
  940. /* these are the functions that do the transformations */
  941. #if defined(PNG_READ_FILLER_SUPPORTED)
  942. extern void png_do_read_filler PNGARG((png_row_info *row_info,
  943.    png_byte *row, png_byte filler, png_byte filler_loc));
  944. #endif
  945.  
  946. #if defined(PNG_WRITE_FILLER_SUPPORTED)
  947. extern void png_do_write_filler PNGARG((png_row_info *row_info,
  948.    png_byte *row, png_byte filler_loc));
  949. #endif
  950.  
  951. #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
  952. extern void png_do_swap PNGARG((png_row_info *row_info, png_byte *row));
  953. #endif
  954.  
  955. #if defined(PNG_READ_PACK_SUPPORTED)
  956. extern void png_do_unpack PNGARG((png_row_info *row_info, png_byte *row));
  957. #endif
  958.  
  959. #if defined(PNG_READ_SHIFT_SUPPORTED)
  960. extern void png_do_unshift PNGARG((png_row_info *row_info, png_byte *row,
  961.    png_color_8 *sig_bits));
  962. #endif
  963.  
  964. #if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
  965. extern void png_do_invert PNGARG((png_row_info *row_info, png_byte *row));
  966. #endif
  967.  
  968. #if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
  969. extern void png_do_gray_to_rgb PNGARG((png_row_info *row_info,
  970.    png_byte *row));
  971. extern void png_set_gray_to_rgb(png_struct *png_ptr);
  972. #endif
  973.  
  974. extern void png_build_grayscale_palette(int bit_depth, png_color *palette);
  975.  
  976. #if defined(PNG_READ_16_TO_8_SUPPORTED)
  977. extern void png_do_chop PNGARG((png_row_info *row_info, png_byte *row));
  978. #endif
  979.  
  980. #if defined(PNG_READ_DITHER_SUPPORTED)
  981. extern void png_do_dither PNGARG((png_row_info *row_info,
  982.    png_byte *row, png_byte *palette_lookup, png_byte *dither_lookup));
  983. extern void png_correct_palette(png_struct *png_ptr, png_color *palette,
  984.    int num_palette);
  985. #endif
  986.  
  987. #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
  988. extern void png_do_bgr PNGARG((png_row_info *row_info, png_byte *row));
  989. #endif
  990.  
  991. #if defined(PNG_WRITE_PACK_SUPPORTED)
  992. extern void png_do_pack PNGARG((png_row_info *row_info,
  993.    png_byte *row, png_byte bit_depth));
  994. #endif
  995.  
  996. #if defined(PNG_WRITE_SHIFT_SUPPORTED)
  997. extern void png_do_shift PNGARG((png_row_info *row_info, png_byte *row,
  998.    png_color_8 *bit_depth));
  999. #endif
  1000.  
  1001. #if defined(PNG_READ_BACKGROUND_SUPPORTED)
  1002. extern void png_do_background PNGARG((png_row_info *row_info, png_byte *row,
  1003.    png_color_16 *trans_values, png_color_16 *background,
  1004.    png_color_16 *background_1,
  1005.    png_byte *gamma_table, png_byte *gamma_from_1, png_byte *gamma_to_1,
  1006.    png_uint_16 **gamma_16, png_uint_16 **gamma_16_from_1,
  1007.    png_uint_16 **gamma_16_to_1, int gamma_shift));
  1008. #endif
  1009.  
  1010. #if defined(PNG_READ_GAMMA_SUPPORTED)
  1011. extern void png_do_gamma PNGARG((png_row_info *row_info, png_byte *row,
  1012.    png_byte *gamma_table, png_uint_16 **gamma_16_table,
  1013.    int gamma_shift));
  1014. #endif
  1015.  
  1016. #if defined(PNG_READ_EXPAND_SUPPORTED)
  1017. extern void png_do_expand_palette PNGARG((png_row_info *row_info,
  1018.    png_byte *row, png_color *palette, png_byte *trans, int num_trans));
  1019. extern void png_do_expand PNGARG((png_row_info *row_info,
  1020.    png_byte *row, png_color_16 *trans_value));
  1021. #endif
  1022.  
  1023. /* unpack 16 and 32 bit values from a string */
  1024. extern png_uint_32 png_get_uint_32 PNGARG((png_byte *buf));
  1025. extern png_uint_16 png_get_uint_16 PNGARG((png_byte *buf));
  1026.  
  1027. /* read bytes into buf, and update png_ptr->crc */
  1028. extern void png_crc_read PNGARG((png_struct *png_ptr, png_byte *buf,
  1029.    png_uint_32 length));
  1030. /* skip length bytes, and update png_ptr->crc */
  1031. extern void png_crc_skip PNGARG((png_struct *png_ptr, png_uint_32 length));
  1032.  
  1033. /* the following decodes the appropriate chunks, and does error correction,
  1034.    then calls the appropriate callback for the chunk if it is valid */
  1035.  
  1036. /* decode the IHDR chunk */
  1037. extern void png_handle_IHDR PNGARG((png_struct *png_ptr, png_info *info,
  1038.    png_uint_32 length));
  1039. extern void png_handle_PLTE PNGARG((png_struct *png_ptr, png_info *info,
  1040.    png_uint_32 length));
  1041. #if defined(PNG_READ_gAMA_SUPPORTED)
  1042. extern void png_handle_gAMA PNGARG((png_struct *png_ptr, png_info *info,
  1043.    png_uint_32 length));
  1044. #endif
  1045.  
  1046. #if defined(PNG_READ_sBIT_SUPPORTED)
  1047. extern void png_handle_sBIT PNGARG((png_struct *png_ptr, png_info *info,
  1048.    png_uint_32 length));
  1049. #endif
  1050.  
  1051. #if defined(PNG_READ_cHRM_SUPPORTED)
  1052. extern void png_handle_cHRM PNGARG((png_struct *png_ptr, png_info *info,
  1053.    png_uint_32 length));
  1054. #endif
  1055.  
  1056. #if defined(PNG_READ_tRNS_SUPPORTED)
  1057. extern void png_handle_tRNS PNGARG((png_struct *png_ptr, png_info *info,
  1058.    png_uint_32 length));
  1059. #endif
  1060.  
  1061. #if defined(PNG_READ_bKGD_SUPPORTED)
  1062. extern void png_handle_bKGD PNGARG((png_struct *png_ptr, png_info *info,
  1063.    png_uint_32 length));
  1064. #endif
  1065.  
  1066. #if defined(PNG_READ_hIST_SUPPORTED)
  1067. extern void png_handle_hIST PNGARG((png_struct *png_ptr, png_info *info,
  1068.    png_uint_32 length));
  1069. #endif
  1070.  
  1071. #if defined(PNG_READ_pHYs_SUPPORTED)
  1072. extern void png_handle_pHYs PNGARG((png_struct *png_ptr, png_info *info,
  1073.    png_uint_32 length));
  1074. #endif
  1075.  
  1076. #if defined(PNG_READ_oFFs_SUPPORTED)
  1077. extern void png_handle_oFFs PNGARG((png_struct *png_ptr, png_info *info,
  1078.    png_uint_32 length));
  1079. #endif
  1080.  
  1081. #if defined(PNG_READ_tIME_SUPPORTED)
  1082. extern void png_handle_tIME PNGARG((png_struct *png_ptr, png_info *info,
  1083.    png_uint_32 length));
  1084. #endif
  1085.  
  1086. #if defined(PNG_READ_tEXt_SUPPORTED)
  1087. extern void png_handle_tEXt PNGARG((png_struct *png_ptr, png_info *info,
  1088.    png_uint_32 length));
  1089. #endif
  1090.  
  1091. #if defined(PNG_READ_zTXt_SUPPORTED)
  1092. extern void png_handle_zTXt PNGARG((png_struct *png_ptr, png_info *info,
  1093.    png_uint_32 length));
  1094. #endif
  1095.  
  1096. /* handle the transformations for reading and writing */
  1097. extern void png_do_read_transformations PNGARG((png_struct *png_ptr));
  1098. extern void png_do_write_transformations PNGARG((png_struct *png_ptr));
  1099.  
  1100. extern void png_init_read_transformations PNGARG((png_struct *png_ptr));
  1101.  
  1102.  
  1103. #endif /* PNG_INTERNAL */
  1104.  
  1105. /* do not put anything past this line */
  1106. #endif /* _PNG_H */
  1107.